home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / elk-2_0.lha / elk-2.0 / contrib / zelk / src-zlib / misc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-17  |  1.7 KB  |  108 lines

  1. /* misc.c - misc routines used by elk extensions
  2.  */
  3.  
  4. #include <theusual.h>
  5.  
  6. /*** common data ***/
  7. Efloat Cflt0 = 0.0;
  8. Efloat Cflt05 = 0.5;
  9. Efloat Cflt1 = 1.0;
  10. Efloat Cflt2 = 2.0;
  11. Efloat CfltPI = 3.1415926535897932384626433832795028841972;
  12. Efloat Cflt2PI = 6.2831853071795864769252867665590057683944;
  13. Efloat CfltPIo2 = 1.5707963267948966192313216916397514420986;
  14. char Ctmpbuf[512];
  15. int Ctmpbuflen = 512;
  16.  
  17.  
  18. /* return a printable representation of the date, in no particular format.
  19.  * arg is a date/type represented as a unsigned long; 
  20.  */
  21. #if Emac
  22. char *Ztimestring
  23. Ztimestring(idate)
  24.   Ztime_t idate;
  25. {
  26.   static char str[40];
  27.   iudatestring(idate,0,str);
  28.   return str;
  29. } /*timestring*/
  30. #endif
  31.  
  32.  
  33. #if Eunix
  34. char *Ztimestring(itime)
  35.   Ztime_t itime;
  36. {
  37.   extern char *ctime();
  38.   char *c,*cp;
  39.   Ztrace(("timestring(%d)\n",itime));
  40.  
  41.   c = ctime(&itime);
  42.  
  43.   /* ctime returns a string which ends with \n. dont like this. */
  44.   for( cp=c; *cp; cp++ ) {
  45.     if (*cp == '\n') {
  46.       *cp = (char)0;
  47.       if (*(cp+1) != (char)0) Zcodeerror("timestring");
  48.     }
  49.   }
  50.  
  51.   return (c);
  52. } /*timestring*/
  53. #endif
  54.  
  55.  
  56.  
  57. /* return a represenatation of the date/time as unsigned long seconds */
  58. #if Emac
  59. Ztime_t Zcurtime()
  60. {
  61.   unsigned int4 i;
  62.   GetDateTime(&i);
  63.   return((Ztime_t)i);
  64. } /*Zcurtime*/
  65. #endif
  66.  
  67. #if Eunix
  68. Ztime_t Zcurtime()
  69. {
  70.  
  71.   return ((Ztime_t)time(NULL));
  72. }
  73. #endif
  74.  
  75.  
  76.  
  77. char *str_end(cp)
  78.   register char *cp;
  79. {
  80.   while (*cp) cp++;
  81.   return (cp);
  82. }
  83.  
  84.  
  85. int /*bool*/ str_any(c, cc)
  86.   register char *c,*cc;
  87. {
  88.   register char *s;
  89.   while(*c) {
  90.     s = cc;
  91.     while (*s)
  92.       if (*s++ == *c)
  93.         return(TRUE);
  94.     c++;
  95.   }
  96.   return(FALSE);
  97. } /*any*/
  98.  
  99.  
  100. char *Zsalloc(str)
  101.   char *str;
  102. {
  103.   char *s;
  104.   s = (char *)malloc(strlen(str)+1);
  105.   strcpy(s,str);
  106.   return(s);
  107. }
  108.